/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bda.mediatheque.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author samsung
 */
@Entity
@Table(name = "exemplaire")
@NamedQueries({
    @NamedQuery(name = "Exemplaire.findAll", query = "SELECT e FROM Exemplaire e")})
public class Exemplaire implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "exemplaireId")
    private Integer exemplaireId;
    @Column(name = "present")
    private boolean present;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "exemplaire")
    private List<Emprunt> empruntList;
    @JoinColumn(name = "item", referencedColumnName = "itemId")
    @ManyToOne(optional = false)
    private Item item;

    public Exemplaire() {
    }

    public Exemplaire(Integer exemplaireId) {
        this.exemplaireId = exemplaireId;
    }

    public Integer getExemplaireId() {
        return exemplaireId;
    }

    public void setExemplaireId(Integer exemplaireId) {
        this.exemplaireId = exemplaireId;
    }

    public List<Emprunt> getEmpruntList() {
        return empruntList;
    }

    public void setEmpruntList(List<Emprunt> empruntList) {
        this.empruntList = empruntList;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }
    
    public boolean getPresent() {
        return present;
    }

    public void setPresent(boolean present) {
        this.present = present;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (exemplaireId != null ? exemplaireId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Exemplaire)) {
            return false;
        }
        Exemplaire other = (Exemplaire) object;
        if ((this.exemplaireId == null && other.exemplaireId != null) || (this.exemplaireId != null && !this.exemplaireId.equals(other.exemplaireId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bda.mediatheque.dao.Exemplaire[ exemplaireId=" + exemplaireId + " ]";
    }
    
}
